package com.hyt.it.ogt.kq.service.gov.photo;

import com.hyt.it.ogt.kq.common.gov.constant.ResponseCode;
import com.hyt.it.ogt.kq.common.config.exception.KqException;
import com.hyt.it.ogt.kq.service.gov.photo.type.PersonalPhoto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 照片工厂类
 * @author huangyh
 * @since 2021-03-25
 */
@Component
public final class PhotoFactory {

    @Autowired
    protected PersonalPhoto personalPhoto;

    private PhotoFactory() {

    }

    public AbstractPhotoTemplate getPhoto(Integer type) throws KqException {
        AbstractPhotoTemplate photo;
        switch (PhotoTypeEnum.getByCode(type)) {
            //考生个人照
            case PERSONAL:
                photo = personalPhoto;
                break;
            //照片类型不存在
            default:
                throw new KqException(ResponseCode.UPLOAD_PHOTO_TYPE_INVALID.getCode(), ResponseCode.UPLOAD_PHOTO_TYPE_INVALID.getMsg());
        }
        return photo;
    }

}
